package com.hbl.wm.mysql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class AppJdbcDelete {
    public static void main(String[] args) throws Exception {
        //加载驱动类
        Class.forName("com.mysql.jdbc.Driver");
        //获取连接
        String url = "jdbc:mysql://localhost:3306/test?useSSL=false";
        String username = "root";
        String password = "316410";
        Connection connection = DriverManager.getConnection(url, username, password);
        //创建陈述对象
        Statement statement = connection.createStatement();
        //执行添加
        String sql = "DELETE FROM `user` WHERE id=2";
        //获取数据
        int i=statement.executeUpdate(sql);
        if(i>0){
            System.out.println("删除成功");
        }

    }
}
